Fix project settings resetting on domain reload #678
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This resolves #524 by avoiding to needlessly save
GvhProjectSettings.xml
on every domain reload.In all 3 modified files, the line
does 3 things on domain reload because of
[InitializeOnLoad]
:GvhProjectSettings.xml
if not already doneGvhProjectSettings.xml
unconditionallylogger.Level
This PR removes step 2) which is unneeded and the cause of #524.
It's potentially possible that writing
GvhProjectSettings.xml
as a result of user interaction might still in some cases have a race condition. I didn't investigate this. However it's much less problematic than intermittent problems on domain reload.Why the problem happens
The current code is correctly protecting critical sections, including saving
GvhProjectSettings.xml
, withlock (classLock)
. However a problem occurs with parallel asset importing enabled in Unity. In this case there are other Unity Editor processes aside from the "main" one that take care of parallel imports. These other processes each have their own separate instance ofclassLock
.This results in multiple processes reading and writing to
GvhProjectSettings.xml
on domain reload. Eventually one of them reads the file while it's being written and ends up with empty settings fromGoogle.ProjectSettings.Load
which it then re-saves. As the screenshot in #524 shows, when corruption happens it's always one or moreVerboseLoggingEnabled
that remain in the settings.About asset import worker processes
The command line of asset import worker processes looks like:
The
-adb2
argument is unique to asset import worker processes so could be used to identify them as needed.Build on Windows
Binaries here https://github.com/berniegp/unity-jar-resolver/releases/tag/v1.2.179
I could not build the plugin as it stands. The (reverted) commit ff03ffd has the changes I needed to do to
build.gradle
.As far as I can see, the build process prefers Unity 5.6. This version (obviously) isn't supported on Apple Silicon so I tried on Windows.
Steps for successful build:
Not sure if I'm doing something wrong regarding the build?